PRO MAIN_LC8Water_Propress

  COMPILE_OPT idl2
  ;  ENVI,/restore_base_save_files
  ;  ENVI_BATCH_INIT

  ;  args = Command_Line_Args(Count=c)
  ;  Landsat_ZipDIR=args[0]
  ;  Landsat_filezZipDIR=args[1]
  ;  ENVIFilepath  =args[2]

  inputpath = 'D:\Lugz\LC81210402020106LGN00\'
  outputpath = 'D:\Lugz\out\'
  VIoutpath = 'D:\Lugz\VIout\'

  shppfile = "D:\Lugz\shp\taihu.shp"

  PRINT, 'GLOVIS_LandsatFilesI begins: ' + SYSTIME(/UTC)
  
  
  ; 2.1 Set the MTL meta File
  LandsatMetaFile = FILE_SEARCH(inputpath,'*_MTL.txt', COUNT=nMTLCount,$
    /TEST_READ, /FULLY_QUALIFY_PATH)

  ; 2.2  Genereate the ENVI file name
  ENVIFileName      = (strsplit(file_basename(LandsatMetaFile), '.', /extract))[0]
  VNIR_SWIRFileName = outputpath+ENVIFileName + '_rad.dat'
  VNIR_SWIRFileName1 = outputpath+ENVIFileName + '_rad_BIL.dat'

  L8CALIBRATE,LandsatMetaFile,VNIR_SWIRFileName,VNIR_SWIRFileName1

  Landsat_FLAASH_LC8,outputpath,ENVIFileName

  output_uri = outputpath+ENVIFileName + '_rad_flaash.dat'
  MAIN_VI_Propress,output_uri,VIoutpath



  PRINT, 'Landsat_PreProcess ends: ' + SYSTIME(/UTC)

end